import { resultSuccess } from '../_util';
import { MockMethod } from 'vite-plugin-mock';

// single
const dashboardRoute = {
  path: '/dashboard',
  name: 'Welcome',
  component: '/dashboard/analysis/index',
  meta: {
    title: '工作台',
    //是否固定标签；
    affix: true,
    icon: 'bx:bx-home',
  },
};

const systemRoute = {
  path: '/system',
  name: 'System',
  component: 'LAYOUT',
  redirect: '/system/dept',
  meta: {
    icon: "ion:settings-outline",
    title: "系统管理"
  },
  children: [
    {
      path: 'dept',
      name: 'DeptManagement',
      // 默认是view下
      component: '/dept/index',
      meta: {
        icon: "ion:settings-outline",
        title: '部门管理',
        // 是否忽略缓存
        ignoreKeepAlive:true
      },
    },
    {
      path: 'menu',
      name: 'MenuPage',
      component: '/menu/index',
      meta: {
        icon: "ion:settings-outline",
        title: '菜单管理',
      },
    },

  ],
};


// TODO 后端菜单路由返回的数据；
export default [
  {
    url: '/basic-api/getMenuListById',
    timeout: 1000,
    method: 'get',
    response: ({ query }) => {
      const { id } = query;
      if (!id || id === '1') {
        return resultSuccess([dashboardRoute, systemRoute]);
      }
      if (id === '2') {
        return resultSuccess([dashboardRoute]);
      }
    },
  },

  {
    url: '/basic-api/getMenuList',
    timeout: 1000,
    method: 'get',
    response: () => {
     return  resultSuccess([dashboardRoute, systemRoute])
    },
  },
] as MockMethod[];

